package main

import "fmt"

func sliceExample() {
	a := []int{1, 2, 3, 4, 5}
	b := a[:]
	fmt.Println(b)
	c := a[1:3]
	fmt.Println(c)
	fmt.Printf("长度：%d 容量：%d\n", len(c), cap(c))
}

func main() {
	var (
		a = 10
		b = 20
	)
	a, b = b, a
	fmt.Println("a =", a, "b =", b)

	if age := 30; age > 20 {
		fmt.Println("age is greater than 20")
	} else {
		fmt.Println("age is less than or equal to 20")
	}
	// fmt.Printf(age) 直接报错
	for i := 0; i < 20; i++ {
		fmt.Println(i)
	}
	var j = 0
	for j < 20 {
		fmt.Println(j)
		j++
	}
	s := "你好 go"
	for k, v := range s {
		fmt.Printf("%v %c\n", k, v)
	}
	// var arr = []string{"apple", "banana", "orange", 1}
	// arr := [...]string{"apple", "banana", "orange"}
	// fmt.Println(arr)
	var bool_arr [5]bool
	bool_arr[0] = true
	fmt.Println(bool_arr, len(bool_arr))

	sliceExample()
}
